package news.yp.newsproject.presenter.model;

import io.reactivex.Flowable;
import news.yp.newsproject.bean.RequestDetailData;
import news.yp.newsproject.bean.RequestPageData;
import news.yp.newsproject.bean.ResponseDetailData;
import news.yp.newsproject.bean.ResponsePageData;
import news.yp.newsproject.bean.ResponseSectionData;
import news.yp.newsproject.network.ApiServiceFactor;
import news.yp.newsproject.network.NetWorkrequest;
import news.yp.newsproject.presenter.presenter.CenterPresenter;

/**
 * Model层，具体实现
 */
public class ModelPresenter implements CenterPresenter.ModelPresenter {
    //获取section
    @Override
    public Flowable<ResponseSectionData> getSectionData() {
        return NetWorkrequest.CreateApiService(ApiServiceFactor.class, ApiServiceFactor.url)
                .requestSection();
    }

    @Override
    public Flowable<ResponsePageData> getpageData(String section, int num, int page) {
        RequestPageData requestPageData = new RequestPageData();
        requestPageData.setSection(section);
        requestPageData.setNum(num);
        requestPageData.setPage(page);
        return NetWorkrequest.CreateApiService(ApiServiceFactor.class, ApiServiceFactor.url)
                .requestPagedata(requestPageData);
    }

    public Flowable<ResponseDetailData> getDetailData(RequestDetailData requestDetailData) {
        return NetWorkrequest.CreateApiService(ApiServiceFactor.class, ApiServiceFactor.url)
                .requestDetailData(requestDetailData);
    }


}
